package org.ucas.kgraph.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.ucas.kgraph.dao.PermDao;
import org.ucas.kgraph.dao.SchemDao;
import org.ucas.kgraph.dto.GraphDto;
import org.ucas.kgraph.dto.ListDto;
import org.ucas.kgraph.entity.Perm;
import org.ucas.kgraph.entity.Relation;
import org.ucas.kgraph.entity.RelationType;
import org.ucas.kgraph.entity.Role;
import org.ucas.kgraph.entity.Schem;
import org.ucas.kgraph.entity.Term;
import org.ucas.kgraph.entity.TermGraph;
import org.ucas.kgraph.utils.exception.BadRequestException;
import org.ucas.kgraph.utils.exception.ConflictException;
import org.ucas.kgraph.utils.exception.ForbiddenException;
import org.ucas.kgraph.utils.exception.NotFoundException;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

@Transactional
@Service
public class PermService {

  @Autowired
  private PermDao permDao;



  public List<Perm> listPermAll() {
	 return permDao.findAll();
  }



  public Perm findById(Long id) {
	// TODO Auto-generated method stub
	  return permDao.findOne(id);
  }



public Collection<String> getAllPerms() {
	// TODO Auto-generated method stub
	Collection<String> res=new ArrayList<String>();
	List<Perm> perms = permDao.findAll();
	for (Perm perm : perms) {
		res.add(perm.getName());
	}
	return res;
}

  
}
